var t = require("../../../@babel/runtime/helpers/defineProperty"), a = getApp();

Page({
    data: {
        configInfo: {},
        reward_total: null,
        reward_amount_total: null,
        reward_type: "1",
        list: [],
        videoTime: 0,
        advertising_apply_id: null,
        ADradioItems: [ {
            value: "1",
            name: "固定金额"
        }, {
            value: "2",
            name: "随机金额",
            checked: "true"
        } ]
    },
    onLoad: function(t) {
        this.getData();
    },
    getData: function() {
        var i = this, n = a.getNetAddresss("plugin.ad-serving.frontend.advertising.index.getPutInAdvertisingData");
        a._postNetWork({
            url: n,
            data: {},
            success: function(a) {
                var n = a.data;
                1 == n.result ? i.setData(t({
                    configInfo: n.data.config,
                    list: n.data.list
                }, "configInfo.min_amount", Number(n.data.config.min_amount) < .01 ? .01 : Number(n.data.config.min_amount))) : wx.showToast({
                    title: n.msg,
                    icon: "none",
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    onChangeADradio: function(t) {
        for (var a = this.data.ADradioItems, i = 0, n = a.length; i < n; ++i) a[i].checked = a[i].value === t.detail.value;
        this.setData({
            ADradioItems: a,
            reward_type: t.detail.value
        });
    },
    selectAdID: function(t) {
        var a = t.currentTarget.dataset;
        this.setData({
            advertising_apply_id: a.id,
            videoTime: a.time
        });
    },
    totalinp: function(t) {
        var a = t.detail.value;
        this.setData({
            reward_total: a
        });
    },
    rewardinp: function(t) {
        var a = t.detail.value;
        this.setData({
            reward_amount_total: a
        });
    },
    submitPut: function() {
        if (Number(this.data.reward_total) < 1) wx.showToast({
            title: "请填写奖励人数",
            icon: "none",
            duration: 1500
        }); else if (Number(this.data.reward_amount_total) < Number(this.data.configInfo.min_amount)) wx.showToast({
            title: "最低奖励金额".concat(this.data.configInfo.min_amount, "元"),
            icon: "none",
            duration: 1500
        }); else if (this.data.advertising_apply_id) if (Number(this.data.videoTime) > Number(this.data.configInfo.video_limit)) wx.showToast({
            title: "视频时长最高为".concat(this.data.configInfo.video_limit, "秒"),
            icon: "none",
            duration: 1500
        }); else {
            var t = {
                reward_total: this.data.reward_total,
                reward_amount_total: this.data.reward_amount_total,
                reward_type: this.data.reward_type,
                put_in_type: "video" == this.options.tag ? "2" : "1",
                put_in_id: this.options.id,
                advertising_apply_id: this.data.advertising_apply_id
            }, i = a.getNetAddresss("plugin.ad-serving.frontend.advertising.index.putInAdvertisingAction");
            a._postNetWork({
                url: i,
                data: t,
                success: function(t) {
                    var a = t.data;
                    wx.showToast({
                        title: a.msg,
                        icon: "none",
                        duration: 1500
                    }), 1 == a.result && wx.navigateBack({
                        delta: 1
                    });
                },
                fail: function(t) {
                    console.log(t.msg);
                }
            });
        } else wx.showToast({
            title: "请选择广告",
            icon: "none",
            duration: 1500
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});